class TagsController < ApplicationController
  before_filter :login_required,:only => [:new,:create,:update]

  def index
    @tags = Tag.all
  
    respond_to do |format|
      format.html 
      format.xml  { render :xml => @tags }
    end
  end

  def new
    @tag = Tag.new

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @tag }
    end
  end
 
  def create
    @tag = Tag.new(:name => params[:name])

      if @tag.save
        redirect_to :controller => "posts"
      else
        render :text => "new"
      end
  end

  
  
  def update
    @tag = Tag.find(params[:id])

    respond_to do |format|
      if @tag.update_attributes(params[:tag])
        flash[:notice] = 'Tag was successfully updated.'
        format.html { redirect_to(@tag) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @tag.errors, :status => :unprocessable_entity }
      end
    end
  end
end
